package com.mzj.saas.mservice.roles.repository;

import com.mzj.saas.mservice.roles.entity.RolePermission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface RolePermissionRepository extends PagingAndSortingRepository<RolePermission, Long>, JpaSpecificationExecutor<RolePermission>,JpaRepository<RolePermission,Long> {
    RolePermission findByRoleIdAndPermissionId(Long roleId, Long permissionId);

    @Transactional
    void deleteAllByRoleId(Long roleId);

    List<RolePermission> findByRoleId(Long roleId);

    List<RolePermission> findByRoleIdIn(List<Long> roleIds);
}
